package net.xiaoyu233.mitemod.miteite.util;

import net.minecraft.EntityPlayer;
import net.minecraft.Packet;
import net.minecraft.World;

public class PlayerUtils {
    public static void sendToAllTrackingPlayers(World world, int x, int z, Packet packet) {
        for (Object playerObj : world.playerEntities) {
            EntityPlayer player = (EntityPlayer) playerObj;

            // 检测玩家是否在区块加载范围内
            if (Math.abs(x - (int)player.posX) < 64 &&
                    Math.abs(z - (int)player.posZ) < 64) {
                ( player).worldObj.sendPacketToAllAssociatedPlayers(player,packet);
            }
        }
    }
}
